import { Matrix4, Vector2, Matrix3, Vector3, Vector4, Color } from "@nirvana/math";
import { WebGLCanvas } from "@nirvana/canvas";
import {
  Camera,
  BallGeometry,
  BoxGeometry,
  PlaneGeometry,
  ConeGeometry,
  CylinderGeometry,
  RingGeometry,
  PipeGeometry,
  Mesh,
  WireframeMesh,
  SimpleMaterial
} from "@nirvana/core";

async function main() {
  // 使用使用 Canvas
  let canvas = document.getElementById("engine-nirvana") as HTMLCanvasElement;
  const webCanvas = new WebGLCanvas(canvas, {});
  const engine = webCanvas.engine;
  const scene = engine.sceneManager.createScene("root");

  const camera = new Camera("root camera", engine);
  scene.addCamera(camera);
  camera.transform.setPosition(0, 0, 10);

  const gl = engine.gl;
  let rows = 8.0,
    columns = 8.0,
    width = 2.0,
    height = 2.0,
    x0 = -width / 2,
    y0 = height / 2,
    xstep = width / columns,
    ystep = -height / rows,
    offset = 3,
    scaling = 0.3;

  for (let row = 0; row < rows; row++) {
    for (let column = 0; column < columns; column++) {
      // row column
      const ballGemotory = new BallGeometry(10, 10, 1);
      const ballMesh = new Mesh(ballGemotory, new SimpleMaterial(""), `ball_${row}_${column}`);
      ballMesh.transform.setPosition((x0 + column * xstep) * offset, (y0 + row * ystep) * offset, 0);
      ballMesh.transform.setScaling(scaling, scaling, scaling);
      scene.addEntity(ballMesh);
    }
  }

  const angle = 0.01;
  engine.update = () => {};
}

main();
